Skip to content

Conversation

@catamorphism
Copy link
Contributor

@catamorphism catamorphism commented Dec 19, 2025

This change makes it possible to change a check to an assertion in the polyfill.

@catamorphism catamorphism force-pushed the remove-check-untilCalendar branch from b380ac7 to 91056e5 Compare December 19, 2025 20:34
@catamorphism catamorphism changed the title Polyfill: Change check to assertion in untiLCalendar Polyfill: Change check to assertion in untilCalendar Dec 19, 2025
@codecov
Copy link

codecov bot commented Dec 19, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.88%. Comparing base (03f9057) to head (8052531).
⚠️ Report is 43 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3218      +/-   ##
==========================================
+ Coverage   96.75%   97.88%   +1.12%     
==========================================
  Files          22       22              
  Lines       10398    10372      -26     
  Branches     1859     1808      -51     
==========================================
+ Hits        10061    10153      +92     
+ Misses        289      199      -90     
+ Partials       48       20      -28     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Collaborator

@ptomato ptomato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found a code snippet that triggers this assertion:

const d1 = Temporal.PlainDateTime.from('2026-01-06T11:02[u-ca=gregory]');
const d2 = Temporal.PlainDateTime.from('2026-01-07T09:02[u-ca=gregory]');
d1.until(d2, { largestUnit: 'years' });

So probably we should consider it a testing coverage gap in any case.

I guess to fix this, we should decide at what level we want to have this early return. As long as it isn't observable, we can do this editorially.

One possibility is to fix all callers of CalendarDateUntil both in the polyfill and spec text so that we can make the assertion in CalendarDateUntil. Another possibility is to just make CalendarDateUntil definitively return if the two dates are equal and then we can make the assertion here in nonISOHelperBase.untilCalendar.

@catamorphism
Copy link
Contributor Author

One possibility is to fix all callers of CalendarDateUntil both in the polyfill and spec text so that we can make the assertion in CalendarDateUntil. Another possibility is to just make CalendarDateUntil definitively return if the two dates are equal and then we can make the assertion here in nonISOHelperBase.untilCalendar.

@ptomato I added the early return in CalendarDateUntil; that seems like the simplest thing. I'll also submit a test262 PR with your test.

@catamorphism
Copy link
Contributor Author

test262 PR: tc39/test262#4813

Copy link
Collaborator

@ptomato ptomato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good now, but could you make the same change to CalendarDateUntil in the spec text?

This change makes it possible to change a check to an assertion in the
polyfill.
@catamorphism catamorphism force-pushed the remove-check-untilCalendar branch from 89ae04b to 09880a9 Compare January 13, 2026 22:35
@catamorphism
Copy link
Contributor Author

Looks good now, but could you make the same change to CalendarDateUntil in the spec text?

Done. Squashed and rebased so I could update the PR title to "Editorial: ..."

@catamorphism catamorphism changed the title Polyfill: Change check to assertion in untilCalendar Editorial: Add early return in CalendarDateUntil Jan 13, 2026
1. If _calendar_ is *"iso8601"*, then
1. Let _sign_ be -CompareISODate(_one_, _two_).
1. If _sign_ = 0, return ZeroDateDuration().
1. Set _sign_ to -sign.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit odd-looking but I'm not sure how else to do it that would make sense.

catamorphism and others added 2 commits January 13, 2026 16:08
Co-authored-by: Philip Chimento <[email protected]>
Co-authored-by: Philip Chimento <[email protected]>
Copy link
Collaborator

@ptomato ptomato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@ptomato ptomato merged commit 264e4b8 into tc39:main Jan 14, 2026
10 checks passed
catamorphism added a commit to catamorphism/proposal-temporal that referenced this pull request Jan 19, 2026
As of tc39#3218 , this check
is always done before calling dateUntil.
ptomato pushed a commit that referenced this pull request Jan 19, 2026
As of #3218 , this check
is always done before calling dateUntil.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants